

package empresa.model;
import java.sql.ResultSet;
import model.BasicBean;



public class SubDistribuidor extends BasicBean {


        public String   idDistribuidor      = "";
        public String   alias               = "";
        public String   password            = "";
        public String   direccion           = "";
        public String   telefono            = "";
        public String   email               = "";
        public String   idPersona           = "";
        public String   idRol               = "";

        public SubDistribuidor() {
        }

        public SubDistribuidor( ResultSet rs ) {
                try {
                        id                  = validateString( rs.getString( "id" ) );
                        idDistribuidor      = validateString( rs.getString( "idDistribuidor" ) );
                        alias               = validateString( rs.getString( "alias" ) );
                        password            = validateString( rs.getString( "password" ) );
                        direccion           = validateString( rs.getString( "direccion" ) );
                        telefono            = validateString( rs.getString( "telefono" ) );
                        email               = validateString( rs.getString( "email" ) );
                        idPersona           = validateString( rs.getString( "idPersona" ) );
                        idRol               = validateString( rs.getString( "idRol" ) );
                } catch ( Exception e ) { System.out.println( e ); }
        }

    @Override
        public String getUpdateSql() {
                String sql = "";
                if( id.equals( "" ) ){
                        sql = "insert into SubDistribuidor( idDistribuidor, alias, password, direccion, telefono, email, idPersona, idRol ) values( '" +
                        idDistribuidor + "', '" +
                        alias + "', '" +
                        password + "', '" +
                        direccion + "', '" +
                        telefono + "', '" +
                        email + "', '" +
                        idPersona + "', '" +
                        idRol + "' )";
                } else {
                        sql = "update SubDistribuidor set idDistribuidor = '" +
                        idDistribuidor + "', alias= '" +
                        alias + "', password= '" +
                        password + "', direccion= '" +
                        direccion + "', telefono= '" +
                        telefono + "', email= '" +
                        email + "', idPersona= '" +
                        idPersona + "', idRol= '" +
                        idRol + "' where id = '" + id + "'";
                }
           return sql;
        }


    @Override
    public String getHtmlRow() {
        String sz = "";

        sz += ("<td class='st4middle'>" + idPersona + "</td>");
        sz += ("<td class='st4middle'>" + direccion + "</td>");
        sz += ("<td class='st4middle'>" + telefono + "</td>");
        sz += ("<td class='st4middle'>" + email + "</td>");
        return sz;
      }




      @Override
    public String getIdentifier() {
        return "idSubDistribuidor=" + id;
    }





   }